package com.heima.apis.schedule;

import com.heima.apis.schedule.fallback.IScheduleFallBack;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.schedule.dots.Task;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

@FeignClient(value = "leadnews-schedule" , fallback = IScheduleFallBack.class)
public interface IScheduleClient {



    /**
     * 添加延时任务 返回的是任务id
     * @param task
     * @return
     */
    @PostMapping("/api/v1/task/add")
    public ResponseResult addTask(@RequestBody Task task );



    /**
     * 取消任务
     * @param taskId
     * @return
     */
    @GetMapping("/api/v1/task/{taskId}")
    public ResponseResult cancelTask(@PathVariable("taskId") Long taskId);

    /**
     * //通过任务type和优先级 从redislist中拉取任务
     * @param type
     * @param priority
     * @return
     */
    @GetMapping("/api/v1/task/{type}/{priority}")
    public ResponseResult pullTask(@PathVariable("type")Integer type ,  @PathVariable("priority")Integer priority);

}
